home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / doupdate.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  3KB  |  111 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    doupdate
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_doupdate = "$Header: C:\CURSES\portable\RCS\doupdate.c 2.1 1993/06/18 20:19:47 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10. /*man-start*********************************************************************
  11.  
  12.   doupdate()    - do effiecient refresh
  13.  
  14.   X/Open Description: (part of the wnoutrefresh() description.)
  15.      These two routines allow multiple updates with more efficiency
  16.      than wrefresh() alone.  In addition to all of the window
  17.      structures representing the terminal screen: a physical screen,
  18.      describing what is actually on the screen and a virtual screen,
  19.      describing what the programmer wants to have on  the screen.
  20.  
  21.      The wrefresh() function works by first calling wnoutrefresh(),
  22.      which copies the named window to the virtual screen.  It then
  23.      calls doupdate(), which compares the virtual screen to the
  24.      physical screen and does the actual update.  If the programmer
  25.      wishes to output several windows at once, a series of cals to
  26.      wrefresh() will result in alternating calls to wnoutrefresh()
  27.      and doupdate(), causing several bursts of output to the
  28.      screen.  By first calling wnoutrefresh() for each window, it
  29.      is then possible to call doupdate() once.  This results in
  30.      only one burst of output, with probably fewer total characters
  31.      transmitted and certainly less CPU time used.
  32.  
  33.   PDCurses Description:
  34.      In addition to the above, if REGISTERWINDOWS is TRUE when the
  35.      library was compiled, any windows registered (true by default
  36.      with PDCurses and _cursvar.refreshall is TRUE, then all
  37.      registered windows will be called via wnoutrefresh() before
  38.      the actual screen update begins.
  39.  
  40.   X/Open Return Value:
  41.      The doupdate() function returns OK on success and ERR on error.
  42.  
  43.   X/Open Errors:
  44.      No errors are defined for this function.
  45.  
  46.   Portability:
  47.      PDCurses    int doupdate( void );
  48.      X/Open Dec '88    int doupdate( void );
  49.      BSD Curses    int doupdate( void );
  50.      SYS V Curses    int doupdate( void );
  51.  
  52. **man-end**********************************************************************/
  53.  
  54. int    doupdate(void)
  55. {
  56. register int    i;
  57. #ifdef    REGISTERWINDOWS
  58.     WINDS*    next = _cursvar.visible;
  59.  
  60. #ifdef PDCDEBUG
  61.     if (trace_on) PDC_debug("doupdate() - called\n");
  62. #endif
  63.  
  64.     if (_cursvar.refreshall)
  65.     {
  66.         while (next != NULL)
  67.         {
  68.             if (next->w->_parent != NULL)
  69.             {
  70.                 touchwin(next->w->_parent);
  71.                 wnoutrefresh(next->w->_parent);
  72.             }
  73.             touchwin(next->w);
  74.             wnoutrefresh(next->w);
  75.             next = next->next;
  76.         }
  77.     }
  78. #endif
  79.     if  (_cursvar.shell)
  80.         reset_prog_mode();
  81.  
  82.     if (curscr == (WINDOW *)NULL)
  83.         return( ERR );
  84.  
  85.     if (curscr->_clear)
  86.     {
  87.         PDC_clr_update(curscr);
  88.     }
  89.     else
  90.     {
  91.         for (i = 0; i < LINES; i++)
  92.         {
  93.             if (curscr->_firstch[i] != _NO_CHANGE)
  94. /*****************************************************/
  95. /* Turn off checking for premature end of refresh    */
  96. /*****************************************************/
  97. /*
  98.                 if (PDC_transform_line(i))
  99.                     break;
  100. */
  101.                 PDC_transform_line(i);
  102.         }
  103.     }
  104.     curscr->_curx = curscr->_curx;
  105.     curscr->_cury = curscr->_cury;
  106.     PDC_gotoxy(curscr->_cury, curscr->_curx);
  107.     _cursvar.cursrow = curscr->_cury;
  108.     _cursvar.curscol = curscr->_curx;
  109.     return( OK );
  110. }
  111.